
const executor = function(resolve, reject){
    if( Math.random() > 0.5 ) {
        resolve('肯定');
    } else {
        reject('否定');
    }
}

const promise = new Promise( executor );

const onResolved = function(value) {
    console.log( 'resolved: ', value );
}

const onRejected = function( value ) {
    console.log( 'rejected: ', value );
}

const ending = function() {
    console.log('finally');
}

promise.then( onResolved ).catch( onRejected ).finally( ending );